#ifndef __GLWIDGET_H__
#define __GLWIDGET_H__ 

#include "src/scene.h"
#include "src/radiosity.h"
#include "src/input.h"

#include <QGLWidget>
#include <QMouseEvent>

namespace Ui {

class GLWidget : public QGLWidget {
	Q_OBJECT
		
public:
	GLWidget(QWidget* = 0);
	~GLWidget();
	
	QSize minimumSizeHint() const;
	QSize sizeHint() const;
		
	t2c2::Radiosity* load_file(const char*);
	void scene_opengl(void);
	
	bool get_shade_model(void);
	void set_shade_model(const bool);
	
public slots:
	void setXRotation(int angle);
	void setYRotation(int angle);
	void setZRotation(int angle);

signals:
	void xRotationChanged(int angle);
	void yRotationChanged(int angle);
	void zRotationChanged(int angle);

	
protected:
	void initializeGL(void);
	void paintGL(void);
	void resizeGL(int,int);
	void mousePressEvent(QMouseEvent *event);
	void mouseMoveEvent(QMouseEvent *event);

	
private:
	void normalizeAngle(int *angle);

	GLuint object;
	t2c2::Scene* scene;
	t2c2::Input input;	

	int xRot;
	int yRot;
	int zRot;
	QPoint lastPos;
	bool shade_model;

};

}

#endif
